#include "label.hpp"
#include "imgui.h"
#include "core/assert.hpp"

using namespace ImGui;

void label::update_data (bindable_base *data)
{
    if (text_)
        text_->attach (data);
}

void label::init_content (const xml_node &node)
{
    ui_control::init_content (node);
    text_ = create_data (node.attribute ("text").as_string (), std_string | c_string);
    PI_ASSERT_MSG (text_ != nullptr, "label control require a text attribute!!");
}

void label::draw_self ()
{
    auto const str = text_->get_std_string ();
    ImGui::Text ("%s", str.c_str ());
}
